/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aal.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author quy
 */
@Entity
@Table(name = "CustomerGroup")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CustomerGroup.findAll", query = "SELECT c FROM CustomerGroup c"),
    @NamedQuery(name = "CustomerGroup.findByCustomerGroupID", query = "SELECT c FROM CustomerGroup c WHERE c.customerGroupID = :customerGroupID"),
    @NamedQuery(name = "CustomerGroup.findByDiscountPercent", query = "SELECT c FROM CustomerGroup c WHERE c.discountPercent = :discountPercent")})
public class CustomerGroup implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy= GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "CustomerGroupID")
    private Integer customerGroupID;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "DiscountPercent")
    private Double discountPercent;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "customerGroupID")
    private Collection<Customer> customerCollection;

    public CustomerGroup() {
    }

    public CustomerGroup(Integer customerGroupID) {
        this.customerGroupID = customerGroupID;
    }

    public Integer getCustomerGroupID() {
        return customerGroupID;
    }

    public void setCustomerGroupID(Integer customerGroupID) {
        this.customerGroupID = customerGroupID;
    }

    public Double getDiscountPercent() {
        return discountPercent;
    }

    public void setDiscountPercent(Double discountPercent) {
        this.discountPercent = discountPercent;
    }

    @XmlTransient
    public Collection<Customer> getCustomerCollection() {
        return customerCollection;
    }

    public void setCustomerCollection(Collection<Customer> customerCollection) {
        this.customerCollection = customerCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (customerGroupID != null ? customerGroupID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CustomerGroup)) {
            return false;
        }
        CustomerGroup other = (CustomerGroup) object;
        if ((this.customerGroupID == null && other.customerGroupID != null) || (this.customerGroupID != null && !this.customerGroupID.equals(other.customerGroupID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.aal.entity.CustomerGroup[ customerGroupID=" + customerGroupID + " ]";
    }
    
}
